package depotTests;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;
import depot.*;

public class GetSetTest {

	private int[] dim1;
	private Parcel pcl;
	private Customer cust;

	/**
	 * Sets up valid Parcel object for use with Customer objects
	 */
	@Before
	public void setUp() {
		dim1 = new int[] {30,30,30};
		pcl = new Parcel("E000112", dim1, 2.55, 2);
		cust = new Customer("000501","Gregor","McCloud",pcl);
	} 

	/**
	 * STAGE 1 - Parcel class
	 * Test all get & set methods
	 */
	@Test
	public final void testGetSetParcel() {

		// Test 1 - getParcelID
		String expected1 = "E000112";
		String message1 = "Failed for getParcelID";
		String actual1 = pcl.getParcelID();
		assertEquals(message1, expected1, actual1);

		// Test 2 - setDimensions & getDimensions & getDimensionsAsString
		// setDimensions
		int[] dim2 = {35,45,55};
		pcl.setDimensions(dim2);
		
		//getDimensions
		int expected2_1 = 35;
		int expected2_2 = 45;
		int expected2_3 = 55;
		int [] dims = pcl.getDimensions();
		int actual2_1 = dims[0];
		int actual2_2 = dims[1];
		int actual2_3 = dims[2];
		assertTrue((actual2_1 == expected2_1) && (actual2_2 == expected2_2) && (actual2_3 == expected2_3));

		// getDimensionsAsString
		String expected2_4 = "35*45*55";
		String message2_4 = "Failed for getDimensionsAsString";
		String actual2_4 = pcl.getDimensionsAsString();
		assertEquals(message2_4, expected2_4, actual2_4);

		// Test 3 - getVolume
		int expected3 = 86625;
		String message3 = "Failed for getVolume";
		int actual3 = pcl.getVolume();
		assertEquals(message3, expected3, actual3);

		// Test 4 - setWeight & getWeight
		// setWeight
		pcl.setWeight(7.77);
		
		// getWeight
		Double expected4 = 7.77;
		String message4 = "Failed for setWeight & getWeight";
		Double actual4 = pcl.getWeight();
		assertEquals(message4, expected4, actual4);

		// Test 5 - setDays & getDays
		// setDays
		pcl.setDays(6);
		
		// getDays
		int expected5 = 6;
		String message5 = "Failed for setDays & getDays";
		int actual5 = pcl.getDays();
		assertEquals(message5, expected5, actual5);

	}

	/**
	 * STAGE 2 - Customer class
	 * Test all get & set methods
	 */
	@Test
	public final void testCalcFeeDiscount() {

		// Test 1 - getCustomerID
		String expected1 = "000501";
		String message1 = "Failed for getCustomerID";
		String actual1 = cust.getCustID();
		assertEquals(message1, expected1, actual1);

		// Test 2 - setFirstName & getFirstName
		// setFirstName
		cust.setFirstName("Billy");
		
		// getFirstName
		String expected2 = "Billy";
		String message2 = "Failed for setFirstName & getFirstName";
		String actual2 = cust.getFirstName();
		assertEquals(message2, expected2, actual2);

		// Test 3 - setLastName & getLastName
		// setLastName
		cust.setLastName("Duffy");
		
		// getLastName
		String expected3 = "Duffy";
		String message3 = "Failed for setLastName & getLastName";
		String actual3= cust.getLastName();
		assertEquals(message3, expected3, actual3);

		// Test 4 - getParcelID
		String expected4 = "E000112";
		String message4 = "Failed for getParcelID";
		String actual4 = pcl.getParcelID();
		assertEquals(message4, expected4, actual4);

		// Test 5 - setParcel & getParcel
		// setParcel
		int[] dim2 = {10,10,10};
		Parcel pcl2 = new Parcel("S000155", dim2, 2.55, 2);
		cust.setParcel(pcl2);
		
		// getParcel
		String expected5 = "S000155";
		String message5 = "Failed for setDays & getDays";
		Parcel pclFromCust = cust.getParcel();
		String actual5 = pclFromCust.getParcelID();
		assertEquals(message5, expected5, actual5);

	} 

}
